﻿@{
    ViewBag.Title = "模型分类列表搜索";
    Layout = "~/Views/Shared/_Main.cshtml";
}
<script type="text/javascript">
    function ButtonSearch() {
        var v = $("#txtCompany").val();
        var n = $("#txtStatus").val();
        $("#DataGrid").datagrid({
            url: "/PEPara/DictModelTypeList/?dbName=" + encodeURI($.getUrlParam("dbName")) + "&name=" + encodeURI(v) + "&status=" + encodeURI(n)
            , pageNumber: 1
        });
    }
    function AddItem() {
        window.location.href = "/PEPara/Edit?dbName=" + encodeURI($.getUrlParam("dbName"));
    }
    function Edit(v) {
        window.location.href = "/PEPara/Edit/?dbName=" + encodeURI($.getUrlParam("dbName")) + "&id=" + v;
    }
    function DeleteItem(v) {
        if (confirm("确定要删除吗？")) { 
            $.post("/PEPara/DeleteMT/?dbName=" + encodeURI($.getUrlParam("dbName")) + "&id=" + v, function (res) {
                switch (res) { 
                    case "1":
                        alert("操作成功！");
                        $("#DataGrid").datagrid('reload');
                        break;
                    case "2":
                        alert("有模型配置引用了该字典配置，不可删除！");
                        break;
                    default:
                        alert(res);
                        break;
                }
            });
        }
    }
    function UpStatus(v, s) {
        $.post("/PEPara/UpdateState/?dbName=" + encodeURI($.getUrlParam("dbName")) + "&id=" + v + "&status=" + s);
        $("#DataGrid").datagrid({
            url: "/PEPara/DictModelTypeList?dbName=" + encodeURI($.getUrlParam("dbName"))
        });
    }
    $(function () {
        $("#DataGrid").datagrid({
            width: 800,
            height: 480,
            autoRowHeight: false,
            fitColumns: true,
            pagination: true,
            rownumbers: true,
            striped: true,
            pageList: [10, 15, 20, 25, 30],
            pageSize: 15,
            title: '模型分类列表',
            iconCls: 'icon-save',
            url: "/PEPara/DictModelTypeList?dbName=" + encodeURI($.getUrlParam("dbName")),
            columns: [[
                { field: 'Name', title: '名称', width: 150 }, 
                { field: 'OrderNo', title: '排序', width: 40 },
                { field: 'Description', title: '描述', width: 300 }, 
                { field: 'Guid', title: '操作', width: 60, align: 'center', formatter: function (value, rowData, rowIndex) {
                    var str = "<a onclick='Edit(\"" + value + "\");' class='grid_a'>修改</a> | <a onclick='DeleteItem(\"" + value + "\");'  class='grid_a'>删除</a>";
                    return str;
                } 
            }
            ]],
            toolbar: [{
                id: 'btnadd',
                text: '新增',
                iconCls: 'icon-add',
                handler: function () {
                    AddItem();
                }
            }]
        });
    }); 
</script>
<div style="margin: 5px;">
    <div class="easyui-panel" style="width: 800px;" data-options="title:'模型分类列表搜索',iconCls:'icon-search'">
        <table>
            <tr>
                <td> 
                    名称：
                    <input id="txtCompany" type="text" class="inputSearch" style="width: 200px;" />
                    <input id="txtStatus" type="hidden" value="1"/> 
                    <input id="buttonSearch" type="button" value=" 搜索 " onclick="ButtonSearch()" />
                </td>
            </tr>
        </table>
    </div>
</div>
<div style="margin-left: 5px;">
    <table id="DataGrid">
    </table>
</div>
